package com.jiajian.cm.service.impl;

import com.jiajian.cm.domain.SysMovie;
import com.jiajian.cm.domain.vo.SysMovieVo;
import com.jiajian.cm.mapper.SysMovieMapper;
import com.jiajian.cm.service.SysMovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysMovieServiceImpl implements SysMovieService {
    @Autowired
    private SysMovieMapper sysMovieMapper;
    @Override
    public List<SysMovie> findAllMovies(SysMovieVo sysMovieVo) {//查询所有电影
        return sysMovieMapper.findAllMovies(sysMovieVo);
    }
    @Override
    public SysMovie findMovieById(Long id) {//根据id查询电影
        return sysMovieMapper.findMovieById(id);
    }
    @Override
    public SysMovie findOneMovie(Long id) {
        return sysMovieMapper.findOneMovie(id);
    }
    @Override
    public int addMovie(SysMovie sysMovie) {//添加电影
        return sysMovieMapper.addMovie(sysMovie);
    }
    @Override
    public int updateMovie(SysMovie sysMovie) {//修改电影
        return sysMovieMapper.updateMovie(sysMovie);
    }
    @Override
    public int deleteMovie(Long[] ids) {//批量删除
        int rows = 0;//删除的行数
        for (Long id : ids) {//循环ids
            rows += sysMovieMapper.deleteMovie(id);//删除一行
        }
        return rows;//返回删除的行数
    }
    /**
     * 总票房榜
     * @return
     */
    @Override
    public List<SysMovie> totalBoxOfficeList() {
        return sysMovieMapper.totalBoxOfficeList();
    }
    /**
     * 国内票房榜 已上映的国内电影里，按票房取前10 国内电影 movieArea in (港台+大陆)
     * @return
     */
    @Override
    public List<SysMovie> domesticBoxOfficeList() {
        return sysMovieMapper.domesticBoxOfficeList();
    }
    /**
     * 国外票房榜 已上映的国外电影里，按票房取前10 国外电影 movieArea not in (港台+大陆)
     * @return
     */
    @Override
    public List<SysMovie> foreignBoxOfficeList() {
        return sysMovieMapper.foreignBoxOfficeList();
    }
}
